

H5x.component("ac-selector",[],function(opts){   
    this.container =  opts.container;
    this.opts = opts;
    
    this.use("render");
    //this.use("emit");

    //this.applistdai = this.dai.create("appsetting"); 
    this.init(); 

},{
    init:function(){ 
        this.render("tp-ac-selector",{
            aclist:this.opts.aclist
        });

        this.showClazz();
       
        var self = this;
        this.container.find("#select-activity").change(function(){
            self.showClazz();
            self.emitChange();
        });

        $("#select-class").change(function(){
            self.emitChange();
        });

        self.emitChange();
    },

    emitChange:function(){
        var activityid = this.container.find("#select-activity").val();
        var clazz = $("#select-class").val();
        var activityno = this.container.find("#select-activity option:selected").attr("data-no");
        if(typeof this.opts.onchange == "function"){
            this.opts.onchange({
                activityid:activityid,
                clazz:clazz,
                activityno:activityno
            });
        }
    },

    showClazz:function(){
        var datacls = this.container.find("#select-activity option:selected").attr("data-class");
        var cls = datacls.split(";");
        $("#select-class").html("<option value='all'>全部班级</option>");
        cls.forEach(function(item){
            $("#select-class").append("<option value='"+item+"'>"+item+"</option>");
        });
    }
});